<?php
if( !defined( 'FORMFIELDHTMLEDIT' ) ): define( 'FORMFIELDHTMLEDIT', 1 );
if( !defined( 'FILE_ROOT' ) ) include_once( '../../_prerun' );

USE_LIB( 'formfieldtext' );

class FormFieldHtmlEdit extends FormFieldText
	{
	/**
	 * identifiant de classe de librairie Javascript
	 * @return string
	 */
	public function jsLibId()	
		{
		return( 'htmledit' );
		}

	/**
	 * code Javascript du controle
	 * @return string
	 */
	public function _getJavascript()	
		{
		$root = WWW_ROOT;
		$html=<<<HTML
			tinyMCE.init({
				mode : "specific_textareas",
				editor_selector : "mceTextSimple",
				plugins : "advlink,advimage,safari,xhtmlxtras,table,style",
				theme : "advanced",
				language : "fr",
				width:"99%",
        		debug : false,
        		convert_urls : false,
        		relative_urls : false,
				document_base_url : "{$root}",
				remove_script_host : false,

				cleanup_on_startup : true,
				inline_styles : true,
				convert_fonts_to_spans : true,
				force_br_newlines : false,
				force_p_newlines : false,
				apply_source_formatting : false,
				
				paste_create_paragraphs : true,
				paste_create_linebreaks : true,
				paste_remove_styles : false,
				paste_strip_class_attributes : 'all',
				paste_convert_middot_lists : false,
				paste_unindented_list_class : "unindentedList",
				paste_convert_headers_to_strong : false,
				paste_auto_cleanup_on_paste : true,
				invalid_elements : "",
				theme_advanced_blockformats : "h1,h2,h3,h4,h5,h6,blockquote,dt,dd,address,p,div,samp",
				theme_advanced_buttons1 : "bold,italic,cite,abbr,acronym,formatselect,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,separator,fontsizeselect,forecolor,separator,image,separator,code,styleprops",
				theme_advanced_buttons2 : "tablecontrols",
				theme_advanced_buttons3 : "",
				
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_path_location : "none",
				extended_valid_elements : "a[name|href|style|class|target|title|onclick|rel],p[align|style|size|class],div[align|style|size|class],strong,ul,li,ol,br,em,img[width|float|style|height|alt|src|class],h1,h2,h3,h4,h5,h6,samp,cite,address,dt,dd,blockquote,span[color|style|size|class],font[color,size]",
				table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
				table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
				table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
				table_cell_limit : 100,
				table_row_limit : 5,
				table_col_limit : 5,
				file_browser_callback : 'myFileBrowser'
			});

		function myFileBrowser(field_name, url, type, win)
			{
			tinyMCE.activeEditor.windowManager.open({
				file : "/_tinymce_files?type=" + type,
				title : 'My File Browser',
				width : 420,
				height : 400,
				resizable : "yes",
				inline : "yes",
				close_previous : "no"
			}, {
				window : win,
				input : field_name
			});
			return false;
		    }
HTML;
		return( $html );
		}
		
		
		
		
	/**
	 * code Javascript du controle
	 * @return string
	 */
	public function _getJavascriptLib()	
		{
		$root = WWW_ROOT;
		$html=<<<HTML
		<script type="text/javascript" src="/scripts/tiny_mce/tiny_mce.js"></script>
HTML;
		return $html;
		}
	}
endif;
?>